
Public Class LoginForm1

    ' TODO: Insert code to perform custom authentication using the provided username and password 
    ' (See http://go.microsoft.com/fwlink/?LinkId=35339).  
    ' The custom principal can then be attached to the current thread's principal as follows: 
    '     My.User.CurrentPrincipal = CustomPrincipal
    ' where CustomPrincipal is the IPrincipal implementation used to perform authentication. 
    ' Subsequently, My.User will return identity information encapsulated in the CustomPrincipal object
    ' such as the username, display name, etc.

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
        open_db("select passwd from m_login where user_id='" & Me.UsernameTextBox.Text & "' and passwd='" & Me.PasswordTextBox.Text & "'")
        With Read
            'rec.Open("select password from m_login where user_id='" & Me.UsernameTextBox.Text & "'", con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly)
            If .Read Then
                Me.Close()
                Main.Show()
            Else
                MsgBox("Wrong username and password", MsgBoxStyle.Information, "Invalid Login")
            End If
        End With
        close_db()
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

    Private Sub LoginForm1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Unit_MaintenanceDataSet.M_Login' table. You can move, or remove it, as needed.
        'Me.M_LoginTableAdapter.Fill(Me.Unit_MaintenanceDataSet.M_Login)

    End Sub
End Class
